var LOGIN = function() 
{
	var o = {};
	
	o.run = function()
	{
		o.userloginin();
	}
	o.userloginin = function()
	{
		$.get('/Api/User/loginin' , null , function(ret){
			if( ret.status == true)
			{
				var html = template('loginin-tql',ret);
				$('#menu-hide').hide();
				$('#menu-show').append(html);
			}
			else
			{
				$('#menu-show').hide();
				$('#menu-hide').show();
			}
		});
	}
	
	o.userloginout = function()
	{
		$.get('/Api/User/loginout' , null , function(ret){
			if( ret.status == true)
			{
				var html = template('loginin-tql',ret);
				window.location.href="/home/index";
				$('#menu-show').hide();
				$('#menu-hide').show();
			}
		});
	}
	
	o.userlogin = function()
	{
		var user 		= $('#user').val();
		var password 	= $('#password').val();
		
		$.get('/Api/User/login' , {user:user , password:password} , function(ret){
			if( ret.count == 0)
			{
				alert( ret.data );
				window.location.href="/home/index";
			}
			else{
				if( ret.count == 1)
				{
					alert( ret.data );
				}
			}
			
		});
	}
	
	o.userregister = function()
	{
		var email 			= $('#email').val();
		var password 		= $('#password').val();
		var passwordRepeat	= $('#passwordRepeat').val();
		
		$.get('/Api/User/register' , {email:email , password:password , passwordRepeat:passwordRepeat} , 
		function(ret){
			if( ret.count == 0)
			{
				alert( ret.data );
				window.location.href="/home/index";
			}
			else
			{
				if( ret.count == 1)
				{
					alert( ret.data );
				}
				else
				{
					alert( ret.data );
				}
			}
		});
	}
	
	return o;
}();




